
var token = sessionStorage.getItem("token");
if (!token) {
    location.href = "http://114.115.133.220/account/src/login/login.html";
}
else {
    $(".add-submit").click(function () {
        let itemVal = $("#item").val(),
            timeVal = $("#time").val(),
            typeVal = $("#type").val(),
            accountVal = $("#account").val(),
            remarksVal = $("#remarks").val(),
            userIdVal = sessionStorage.getItem("id") || "";
        if (!itemVal || !timeVal || !typeVal || !accountVal || !remarksVal) {
            return alert("有一项为空");
        }
        $.ajax({
            type: "POST",
            url: "http://114.115.133.220:2023/api/add",
            data: {
                title: itemVal,
                time: timeVal,
                type: Number(typeVal),
                account: Number(accountVal),
                remarks: remarksVal,
                userId: userIdVal
            },
            headers: {
                token: token,
            },
            dataType: "json",
            success: function (res) {
                if (res.code === "10000") {
                    alert("添加成功");
                    location.href = "http://114.115.133.220/account/src/list/list.html";
                }
                else {
                    alert(res.message);
                }
            }
        })
    })
}
